import 'package:enjoy_plus/pages/house/add_house_from.dart';
import 'package:enjoy_plus/pages/house/components/list_item.dart';
import 'package:flutter/material.dart';

class RoomList extends StatefulWidget {
  const RoomList({super.key, required this.building, required this.community});
  final String building;
  final String community;

  @override
  State<RoomList> createState() => _RoomListState();
}

class _RoomListState extends State<RoomList> {
  //楼栋数据
  late List<String> rooms;

  @override
  void initState() {
    super.initState();
    rooms = List.generate(10, (index) => '${index + 1}室');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('选择房间'),
        backgroundColor: const Color(0xFFF1F2F6),
        centerTitle: true,
        leading: IconButton(
            onPressed: () => Navigator.pop(context),
            icon: const Icon(Icons.arrow_back_ios)),
      ),
      body: Container(
        color: const Color(0xFFF1F2F6),
        child: Column(
          children: [
            ...rooms
                .map((room) => RoomListItem(
                      room: '${widget.community}${widget.building} $room',
                      onPressed: () {
                        Navigator.pushNamed(context, '/addHouseFrom',
                            arguments: {
                              'community': widget.community,
                              'building': widget.building,
                              'room': room
                            });
                      },
                    ))
                .toList(),
          ],
        ),
      ),
    );
  }
}
